package com.danawa.watcher.front;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.danawa.watcherApi.database.domain.BaseProduct;
import com.danawa.watcherApi.database.service.WatcherService;

@Controller 	
public class MainController {
	
	@Autowired 
	WatcherService watcherService;
	
	@RequestMapping(value ="/index.html" , method = RequestMethod.GET)
	public String versionCheck(ModelMap modelMap, HttpServletRequest request){
		BaseProduct baseProduct = new BaseProduct();
		List<BaseProduct> data = new ArrayList<BaseProduct>();
		try {
			data = watcherService.getBaseProducts(baseProduct);
		} catch (Throwable e) {
			e.printStackTrace();
		}
		modelMap.addAttribute("data", data );
		return "main/index";
	}
}
